package Test;

import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CTabFolder;
import org.eclipse.swt.custom.CTabItem;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;

public class Test {

/**
* @param args
*/
public static void main(String[] args) {
   Display display = new Display();
   Shell shell = new Shell(display);
   shell.setSize(300, 200);
   shell.setLayout(new FillLayout());
   shell.setText("自定义选项卡");
  
   // 选项卡样式：带有“关闭”按钮、带有边框
   final CTabFolder tabFolder = new CTabFolder(shell, SWT.TOP | SWT.CLOSE | SWT.BORDER);
   tabFolder.setTabHeight(20);
   tabFolder.setLayout(new FillLayout());
   tabFolder.marginHeight = 10;
   tabFolder.marginWidth = 10;
   // 显示“最大化、最小化”按钮
   tabFolder.setMaximizeVisible(true);
   tabFolder.setMinimizeVisible(true);
  
   for (int i = 0; i < 4; i++) {
    CTabItem item = new CTabItem(tabFolder, SWT.NONE);
    item.setText("选项卡 " + i);
    Text t = new Text(tabFolder, SWT.MULTI);
    t.setBounds(5, 5, 150, 150);
    t.setText("这是第 " + i + " 页");
    item.setControl(t);
   }
   tabFolder.pack();

   shell.open();
   shell.layout();
  
   while (!shell.isDisposed()) {
    if (!display.readAndDispatch()) {
     display.sleep();
    }
   }
   display.dispose();  
}

}
